package client

import (
	"bufio"
	"fmt"
	"net"
	"os"
	"strings"
)

func main() {
	conn, err := net.Dial("tcp", "127.0.0.1:8888")
	if err != nil {
		println(err)
	} else {
		reader := bufio.NewReader(os.Stdin) //os.Stdin标准输入
		for {
			readString, err := reader.ReadString('\n')
			if err != nil {
				println("err", err)
			}
			readString = strings.Trim(readString, "\r\n")
			if readString == "exit" {
				println("退出")
				break
			}
			n, err := conn.Write([]byte(readString))
			if err != nil {
				println(err)
			} else {
				fmt.Printf("发送了%d字节的数据", n)
			}
		}

	}
}
